<template>
  <section class="recommend_company_list">
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
      :offset="200"
      :immediate-check="false"
      class="job_list_items"
    >
      <div class="item" v-for="item in list" :key="item.id">
        {{ item.name }}
        <span @click="linkTo(item.id)"
          >查看<van-icon class="filter-items-icons" name="arrow"
        /></span>
      </div>
    </van-list>
  </section>
</template>
<script>
import { getRecommendCompany } from '@/api/company'
export default {
  name: 'RecommendCompany',
  data() {
    return {
      params: {
        page: 1,
        size: 30,
        recommend: true,
      },
      list: [],
      loading: false,
      finished: false,
    }
  },
  async created() {
    await this.getRecommendCompany()
  },
  methods: {
    async getRecommendCompany() {
      const res = await getRecommendCompany(this.params)
      const { page, size } = this.params
      const list = res.content || []
      if (page == 1) {
        this.list = list
      } else {
        this.list = this.list.concat(list)
      }
      if (list.length < size) {
        this.finished = true
      } else {
        this.finished = false
        this.params.page = this.params.page + 1
      }
    },
    async onLoad() {
      await this.getRecommendCompany(this.params)
    },
    linkTo(id) {
      this.$router.push(`/recommendCompany/${id}`)
    },
  },
}
</script>
<style lang='less' scoped>
.recommend_company_list {
  padding-top: 10px;
  .item {
    background: white;
    padding: 5px 20px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    line-height: 30px;
    align-items: center;
    color: #333;
    font-size: 14px;
    span {
      display: inline-flex;
      align-items: center;
      justify-content: flex-end;
      width: 150px;
      color: #7ac5ef;

      .filter-items-icons {
        font-size: 10px;
        // color: #666666;
      }
    }
  }
}
</style>